<script setup>

import router from "@/router/index.js";
import {ref} from "vue";
//返回登录界面
const back = ()=>{
  router.push({name:'Login'})
}
//注册数据模型
const registerData = ref({
  username:'',
  password:'',
  rePassword:''
})
import {registerService} from "@/api/Register.js";
//注册
const register =async ()=>{
  const msgDiv = document.querySelector('.message')
  if(registerData.value.password !== registerData.value.rePassword){
    msgDiv.innerHTML='两次输入的密码不一致'
  }else {
    const result = await registerService(registerData.value)
    if(result.code === 2){
      msgDiv.innerHTML = result.msg
    }else if(result.code === 0) {
      msgDiv.innerHTML='注册成功'
    }
  }

  setTimeout(()=>{
    msgDiv.innerHTML=''
  },2000)
}
</script>
<template>
  <div class="bg">
  <div class="container">
    <div class="row">
      <div class="col-md-8">
        <div class="font-left">
          <p>
            <h1>智能简历分析系统</h1>
          </p>
          <p>
            <h3>My dream is the starry sea, and you?</h3>
          </p>
        </div>
      </div>
      <div class="col-md-4">
        <div class="t1">
          <div class="dltop">
            <h1 class="text-center">欢迎注册</h1>
          </div>
           <div>
              <form>
                  <div class="row form-row">
                    <div class="col-md-2">
                      <p class="text-center font-denglu">
                          用户名
                      </p>
                    </div>
                    <div class="col-md-9">
                      <input type="text" class="form-control" placeholder="用户名"  v-model="registerData.username" name="pswd">
                    </div>
                  </div>
                  <div class="row form-row">
                      <div class="col-md-2">
                        <p class="text-center font-denglu">
                            密码
                        </p>
                      </div>
                      <div class="col-md-9">
                        <input type="password" class="form-control" placeholder="请输入密码"  v-model="registerData.password" name="pswd">
                      </div>
                  </div>
                  <div class="row form-row">
                    <div class="col-md-2">
                      <p class="text-center font-denglu">
                        确认密码
                      </p>
                    </div>
                    <div class="col-md-9">
                      <input type="password" class="form-control" placeholder="请再次输入密码" v-model="registerData.rePassword" name="pswd">
                    </div>
                  </div>
                  <div class="message">

                  </div>
                    <div class="col-md-12 text-center btn">
                      <button type="button" class="btn btn-primary col-md-8 btn-r" @click="register()">注册</button>
                      <button type="button" style="margin-top: 20px" class="btn btn-primary col-md-8 btn-r" @click="back()">返回</button>
                    </div>
                </form>
          </div>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>

<style scoped>
.bg{
  background-image: url(../../assets/images/2b29d1d0d8690b37173dcddfd091f75.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  width: 100%;
  height: 100%;
  position: fixed;
  left: 0;
  top: 0;
}
.t1{
  margin:100px 0 200px 0;
  height: 600px;
  width: 500px;
  border: 2px white;
  border-radius: 10%;
  background-color: rgba(255, 255, 255, 0.56);
  box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(5px);
}
.font-left{
  color:white;
  text-align: center;
  margin:200px auto 200px auto;
}
.dltop{
  height: 120px;
  margin-top: 50px;
  margin-bottom: 10px;
}
.dltop h1{
  line-height: 120px;
}
.font-denglu{
  line-height: 38px;
  /* font-size: larger; */
  font-weight: bolder;
  width: 100px;
}
form{
  padding-left: 20px;
}
.row{
  margin-bottom: 8px;
  margin-top: 5px;
}
.btn-r{
  margin-left: 30px;
}
.btn{
  margin-top: 5px;
}
.message{
  margin-left: 40%;
  font-size: large;
  font-weight: bolder;
  color: red;
  height: 40px;
}
</style>